﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace SimpleBomberman
{
    public class Enemy : GameObject
    {
        #region Private Members

        private int _direction;

        private bool _leftFlag;
        private bool _rightFlag;
        private bool _upFlag;
        private bool _downFlag;

        #endregion Private Members

        #region Properties

        public int Direction
        {
            get
            {
                return _direction;
            }
            set
            {
                this._direction = value;
            }
        }
        public bool LeftFlag
        {
            get
            {
                return _leftFlag;
            }
            set
            {
                this._leftFlag = value;
            }
        }
        public bool RightFlag
        {
            get
            {
                return _rightFlag;
            }
            set
            {
                this._rightFlag = value;
            }
        }
        public bool UpFlag
        {
            get
            {
                return _upFlag;
            }
            set
            {
                this._upFlag = value;
            }
        }
        public bool DownFlag
        {
            get
            {
                return _downFlag;
            }
            set
            {
                this._downFlag = value;
            }
        }

        #endregion Properties

        #region Constructors

        public Enemy() : base()
        {
            this._direction = 1;

            this._leftFlag = false;
            this._rightFlag = false;
            this._upFlag = false;
            this._downFlag = false;
        }
        public Enemy(int x, int y, int length) : base(x, y, length)
        {
            this._direction = 1;

            this._leftFlag = false;
            this._rightFlag = false;
            this._upFlag = false;
            this._downFlag = false;
        }

        #endregion Constructors

        #region Public Methods

        public override void Draw(Graphics g)
        {
            Pen blackPen = new Pen(Color.Black, 1);
            Pen whitePen = new Pen(Color.White, 1);

            //------- Red colors -------
            //--- Body ---
            g.FillPolygon(Brushes.Red, new Point[] { 
                new Point(this.X + 7, this.Y + 0), new Point(this.X + 22, this.Y + 0), 
                new Point(this.X + 22, this.Y + 2), new Point(this.X + 26, this.Y + 2), 
                new Point(this.X + 26, this.Y + 6), new Point(this.X + 28, this.Y + 6), 
                new Point(this.X + 28, this.Y + 17), new Point(this.X + 26, this.Y + 17), 
                new Point(this.X + 26, this.Y + 21), new Point(this.X + 24, this.Y + 21), 
                new Point(this.X + 24, this.Y + 23), new Point(this.X + 22, this.Y + 23), 
                new Point(this.X + 22, this.Y + 25), new Point(this.X + 19, this.Y + 25), 
                new Point(this.X + 19, this.Y + 29), new Point(this.X + 11, this.Y + 29), 
                new Point(this.X + 11, this.Y + 25), new Point(this.X + 7, this.Y + 25), 
                new Point(this.X + 7, this.Y + 23), new Point(this.X + 5, this.Y + 23), 
                new Point(this.X + 5, this.Y + 21), new Point(this.X + 3, this.Y + 21), 
                new Point(this.X + 3, this.Y + 17), new Point(this.X + 1, this.Y + 17), 
                new Point(this.X + 1, this.Y + 6), new Point(this.X + 3, this.Y + 6), 
                new Point(this.X + 3, this.Y + 2), new Point(this.X + 7, this.Y + 2)});

            //------- Black lines -------
            //--- Contours ---
            g.DrawPolygon(blackPen, new Point[] { 
                new Point(this.X + 7, this.Y + 0), new Point(this.X + 22, this.Y + 0), 
                new Point(this.X + 22, this.Y + 2), new Point(this.X + 26, this.Y + 2), 
                new Point(this.X + 26, this.Y + 6), new Point(this.X + 28, this.Y + 6), 
                new Point(this.X + 28, this.Y + 17), new Point(this.X + 26, this.Y + 17), 
                new Point(this.X + 26, this.Y + 21), new Point(this.X + 24, this.Y + 21), 
                new Point(this.X + 24, this.Y + 23), new Point(this.X + 22, this.Y + 23), 
                new Point(this.X + 22, this.Y + 25), new Point(this.X + 19, this.Y + 25), 
                new Point(this.X + 19, this.Y + 29), new Point(this.X + 11, this.Y + 29), 
                new Point(this.X + 11, this.Y + 25), new Point(this.X + 7, this.Y + 25), 
                new Point(this.X + 7, this.Y + 23), new Point(this.X + 5, this.Y + 23), 
                new Point(this.X + 5, this.Y + 21), new Point(this.X + 3, this.Y + 21), 
                new Point(this.X + 3, this.Y + 17), new Point(this.X + 1, this.Y + 17), 
                new Point(this.X + 1, this.Y + 6), new Point(this.X + 3, this.Y + 6), 
                new Point(this.X + 3, this.Y + 2), new Point(this.X + 7, this.Y + 2)});

            g.DrawPolygon(blackPen, new Point[] { 
                new Point(this.X + 8, this.Y + 1), new Point(this.X + 21, this.Y + 1), 
                new Point(this.X + 21, this.Y + 3), new Point(this.X + 25, this.Y + 3), 
                new Point(this.X + 25, this.Y + 7), new Point(this.X + 27, this.Y + 7), 
                new Point(this.X + 27, this.Y + 16), new Point(this.X + 25, this.Y + 16), 
                new Point(this.X + 25, this.Y + 20), new Point(this.X + 23, this.Y + 20), 
                new Point(this.X + 23, this.Y + 22), new Point(this.X + 21, this.Y + 22), 
                new Point(this.X + 21, this.Y + 24), new Point(this.X + 18, this.Y + 24), 
                new Point(this.X + 18, this.Y + 28), new Point(this.X + 12, this.Y + 28), 
                new Point(this.X + 12, this.Y + 24), new Point(this.X + 8, this.Y + 24), 
                new Point(this.X + 8, this.Y + 22), new Point(this.X + 6, this.Y + 22), 
                new Point(this.X + 6, this.Y + 20), new Point(this.X + 4, this.Y + 20), 
                new Point(this.X + 4, this.Y + 16), new Point(this.X + 2, this.Y + 16), 
                new Point(this.X + 2, this.Y + 7), new Point(this.X + 4, this.Y + 7), 
                new Point(this.X + 4, this.Y + 3), new Point(this.X + 8, this.Y + 3)});

            //--- Left eye ---
            g.FillRectangle(Brushes.Black, this.X + 10, this.Y + 12, 2, 3);

            //--- Right eye ---
            g.FillRectangle(Brushes.Black, this.X + 18, this.Y + 12, 2, 3);

            //--- Mouse ---
            g.FillRectangle(Brushes.Black, this.X + 13, this.Y + 20, 4, 2);

            //------- White colors -------
            //--- Left eye ---
            g.FillRectangle(Brushes.White, this.X + 9, this.Y + 10, 4, 2);
            g.DrawLine(whitePen, this.X + 9, this.Y + 12, this.X + 9, this.Y + 15);
            g.DrawLine(whitePen, this.X + 12, this.Y + 12, this.X + 12, this.Y + 15);
            g.DrawLine(whitePen, this.X + 10, this.Y + 15, this.X + 11, this.Y + 15);

            //--- Right eye ---
            g.FillRectangle(Brushes.White, this.X + 17, this.Y + 10, 4, 2);
            g.DrawLine(whitePen, this.X + 17, this.Y + 12, this.X + 17, this.Y + 15);
            g.DrawLine(whitePen, this.X + 20, this.Y + 12, this.X + 20, this.Y + 15);
            g.DrawLine(whitePen, this.X + 18, this.Y + 15, this.X + 19, this.Y + 15);

            //--- Down line ---
            g.FillRectangle(Brushes.White, this.X + 13, this.Y + 26, 4, 2);
        }

        #endregion Public Methods
    }
}
